CREATE PROC SP_CREATE_UPDATE_COST_CODES(

	@COSTCODE 	VARCHAR(50),
	@MKTPARTNUMBER 	VARCHAR(50)

)
AS
BEGIN
		
	DECLARE @PROCESSSTEP_ID INT
	
	SET @PROCESSSTEP_ID = 0

	Select @PROCESSSTEP_ID = CONVERT(VARCHAR, PROCESSSTEP_ID) from PRODUCT where P_Marketing_Part_Number = @MKTPARTNUMBER 

	IF @PROCESSSTEP_ID > 0
	BEGIN
		UPDATE PRODUCT SET COST_CODE = @COSTCODE 
		WHERE PROCESSSTEP_ID IN ( SELECT PROCESSSTEP_ID FROM 
		FN_GET_PROCESS_FLOW_BY_PROCESSSTEP_ID ( @PROCESSSTEP_ID ))
	END
	
END